/*-----------------------------------------------------------------------------
-通用开发平台:基本组件的始类
-作者：张金军
-所有人：张金军
-版权：版权所有，张金军，2005-2015，保留所有权利
-----------------------------------------------------------------------------*/

/*平台基本类
* 最基本 属性 的 定义
*/
Yxt.core.Observe =function(){
	
	this.classID      = "";
	this.classType    = "";
	this.className    = "Observe";
	this.classAddress = "yxt.core.Observe";
	this.classParent  = Object;
	
	//this.events       = new Yxt.util.Enum();
};

Yxt.core.Observe.prototype={	
		
		setClassID:function(fid)
		{
			this.classID = fid;	
		},
		getClassID:function()
		{
			return this.classID;			
		},		
		getClassType:function()
		{
			return this.classType;			
		},		
		getClassName:function()
		{
			return this.className;			
		},
		getClassAddress:function()
		{
			return this.classAddress;			
		},
		addComponents:function(Component)
		{
			
		},
		addEvents:function(events)
		{
			
		},
		
		destroy:function()
		{
			delete this;
		}
};


Yxt.core.Component = function(conText)
{
	
	this.tagIndex   = 0;	
	
	this.left      = 0;
	this.top       = 0;
	this.width     = 0;
	this.height    = 0;    
    
	this.visible   = true; 
	this.enabled   = true;
	this.classStyle = "";
	/*
	 * 控件实体对象
	 */
	this.element;
	/*
	 * 控件依附对象
	 */
	this.attachObj;
	this.renderTo;
	
	this.doc   = document;
	this.body  = document.body;
	
	Yxt.core.Observe.call(this);
}

Yxt.core.Component =Yxt.extend(Yxt.core.Component,Yxt.core.Observe,{	
	
	create:function(){
	
    },
    
    setHeight:function(height)
    {
    	this.height = height;
    },
    setWidth:function(width)
    {
    	this.width = width;
    },
    setLeft:function(left)
    {
    	this.left = left;
    },
    setTop:function(top)
    {
    	this.top = top;
    },
    
	getStyle:function(styleName)
	{
    	if(this.element)
    		return  this.element.style.getAttribute(styleName);
    	else
    		return "";
	},
    setStyle:function(styleName,styleValue)
	{
    	if(this.element)
    		this.element.style.setAttribute(styleName,styleValue);
    	
	},
	getAttachObj:function(renderTo)
	{
		
		this.renderTo = renderTo||this.body;
			
		if(Yxt.isElement(this.renderTo))
			this.attachObj = this.renderTo
		else if(Yxt.isObject(this.renderTo))
		{
			this.attachObj= this.renderTo.element;;			
		}	
		else if(Yxt.isString(this.renderTo))
		{
			this.attachObj =this.doc.getElementById(this.renderTo);
		}
		
		return this.attachObj ;
	},
	getAttachID:function()
	{
		if(Yxt.isElement(this.attachObj))
			return this.attachObj.getAttribute("id");
		else 
			return "";
	},
	createElement:function(tag)
	{
		this.element = this.doc.createElement(tag);
		return this.element;
	},
	add:function(child,parent)
	{
		if(Yxt.isObject(child))
		{
			if (parent)
				parent.appendChild(child.element);
			else
				this.body.appendChild(child.element);
		}else if(Yxt.isElement(child))
		{
			if (parent)
				parent.appendChild(child);
			else
				this.body.appendChild(child);
		}			
	},
    remove:function(child,parent)
	{
		if(Yxt.isObject(child))
		{
			if (parent)
				parent.removeChild(child.element);
			else
				this.body.removeChild(child.element);
		}else if(Yxt.isElement(child))
		{
			if (parent)
				parent.removeChild(child);
			else
				this.body.removeChild(child);
		}			
	},
	addEvents:function(event,func)
	{
	
		eval("this.element."+event +"=this."+ func);
	}
	
	
});



Yxt.ComMag={
		
		mags:new ListMap(),
		
		get:function(comID,conText)
		{
			
			var comTarget;
			comTarget = this.mags.get(comID);
			
			if (comTarget == null)
			{
				
				switch (comID)
				{
					case "listContainer":{
						comTarget = new Yxt.widget.ListContainer();
						this.mags.put(comID,comTarget);
						break;
					}case "shim":{
						comTarget = new Yxt.widget.Shim();
						this.mags.put(comID,comTarget);
						break;
					}case "calendar":{
						comTarget = new Calendar();
						this.mags.put(comID,comTarget);
						break;
					}					
				}			
			}
			if (conText)
				comTarget.setConText(conText);
			//if (comID=="calendar")
				//comTarget.hide();
			
			return comTarget;
					
		}
}

